<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    let n1,n2 = 123,n3 = null,n4 = true,n5 = 'hello', n6 = '',n7 = 0;
    console.log(Boolean(n1));//将未定义转换为布尔型
    console.log(Boolean(n2));//非0数值转布尔型
    console.log(Boolean(n3));//null转为布尔型
    console.log(Boolean(n5));//非空字符转布尔型
    console.log(Boolean(n6));//空字符串转布尔型
    console.log(Boolean(n7));//0转布尔型
    //未定义，null,空字符串，0转化为布尔型结果为false
    //非0数值和非空字符转换为布尔型结果true
    console.log('-----------');
    console.log(Number(n6));
    console.log(parseInt(n6));
    console.log(parseFloat(n6));
    let num = parseInt(n6);
    console.log(num);
    console.log(typeof(num));
    console.l(Boolean(num));
</script>
</html>